package com.atguigu.day17.test08;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * @author fenge
 */
public class Test01{
    public static void main(String[] args) {
        Student s1 = new Student("liusan",20,90.0);
        Student s2 = new Student("lisi",22,90.0);
        Student s3 = new Student("wangwu",20,99.0);
        Student s4 = new Student("sunliu",22,100.0);
        Student[] students = {s1,s2,s3,s4};
        Arrays.sort(students);
        System.out.println(Arrays.toString(students));
        List<Student> studentList = new ArrayList<>();
        Arrays.sort(students, new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        System.out.println(Arrays.toString(students));
    }
}
